import Vue from "vue";
import VueRouter from "vue-router";

Vue.use(VueRouter);

//引入布局组件
import Layout from "../views/Layout/index.vue";

export const defaultRouterMap = [
  {
    path: "/",
    redirect: "login",
    hidden: true
  },
  {
    path: "/login",
    name: "Login",
    hidden: true,
    meta: {
      name: "登录页"
    },
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "login" */ "../views/Login/index.vue")
  },
  {
    path: "/home",
    name: "Home",
    redirect: "index",
    meta: {
      name: "控制台",
      icon: "dashboard"
    },
    component: Layout,
    children: [
      {
        path: "/index",
        name: "Index",
        meta: {
          name: "首页"
        },
        component: () => import(/* webpackChunkName: "home" */ "../views/Home/index.vue")
      }
    ]
  },
  {
    path: "/vue3test",
    name: "vue3test",
    hidden: true,
    meta: {
      name: "vue3api测试页"
    },
    component: () => import(/* webpackChunkName: "vue3test" */ "../views/vue3test/index.vue")
  }
];

export const asyncRouterMap = [
  {
    path: "/article",
    name: "Article",
    meta: {
      name: "文章管理",
      icon: "article"
    },
    component: Layout,
    children: [
      {
        path: "/article/index",
        name: "article-list",
        meta: {
          name: "文章列表"
        },
        component: () => import(/* webpackChunkName: "home" */ "../views/Article/index.vue")
      },
      {
        path: "/article/category",
        name: "article-cate",
        meta: {
          name: "文章分类"
        },
        component: () => import(/* webpackChunkName: "home" */ "../views/Article/category.vue")
      },
      {
        path: "/article/detail",
        name: "article-detail",
        hidden: true,
        meta: {
          name: "文章详情"
        },
        component: () => import(/* webpackChunkName: "home" */ "../views/Article/detail.vue")
      }
    ]
  },
  {
    path: "/user",
    name: "User",
    meta: {
      name: "用户管理",
      icon: "user"
    },
    component: Layout,
    children: [
      {
        path: "/user/index",
        name: "user-list",
        meta: {
          name: "用户列表"
        },
        component: () => import(/* webpackChunkName: "home" */ "../views/User/index.vue")
      }
    ]
  }
];

// const routes = [
//
// ];

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes: defaultRouterMap
});

export default router;
